<script setup lang="ts">
import { computed } from 'vue'
import FileBrowser from './components/FileBrowser.vue'
import SvgIcon from './components/SvgIcon.vue'

// 动态获取服务器地址
const serverAddress = computed(() => {
  const hostname = window.location.hostname
  const port = window.location.port
  return `${hostname}:${port} (代理到后端)`
})
</script>

<template>
  <div id="app">
    <div class="app-header">
      <div class="app-title">
        <h1><SvgIcon name="folder" :size="28" /> FileHive - 局域网文件共享</h1>
        <p class="app-subtitle">轻松分享文件，快速访问数据</p>
      </div>
      <div class="app-info">
        <span class="server-info">服务器: {{ serverAddress }}</span>
      </div>
    </div>
    
    <div class="app-body">
      <FileBrowser />
    </div>
  </div>
</template>

<style lang="less">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1f2937;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.025em;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  
  .app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
    color: #1f2937;
    position: relative;
    
    &::before {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 252, 0.7));
      z-index: -1;
    }
    
    .app-title {
      h1 {
        font-size: 24px;
        font-weight: 600;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 12px;
        color: #1f2937;
        letter-spacing: -0.02em;
      }
      
      .app-subtitle {
        font-size: 14px;
        color: #6b7280;
        margin: 4px 0 0 0;
        font-weight: 400;
        opacity: 0.8;
      }
    }
    
    .app-info {
      .server-info {
        background: rgba(248, 250, 252, 0.8);
        border: 1px solid rgba(229, 231, 235, 0.8);
        padding: 8px 16px;
        border-radius: 12px;
        font-size: 13px;
        font-weight: 500;
        color: #4b5563;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        letter-spacing: 0;
        transition: all 0.2s ease;
        
        &:hover {
          background: rgba(243, 244, 246, 0.9);
          transform: translateY(-1px);
          box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
      }
    }
  }
  
  .app-body {
    flex: 1;
    overflow: hidden;
  }
}

// 滚动条样式 - 现代化设计
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #d1d5db, #9ca3af);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: all 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

// 工具提示样式
[title] {
  position: relative;
}

// 选择文本样式
::selection {
  background: rgba(59, 130, 246, 0.2);
  color: #1e40af;
}

// 表单元素样式重置
input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

// 按钮基础样式
button {
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  
  &:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
}

// 输入框焦点样式
input:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

// 响应式设计
@media (max-width: 768px) {
  #app {
    .app-header {
      padding: 12px 20px;
      
      .app-title {
        h1 {
          font-size: 20px;
          gap: 8px;
        }
        
        .app-subtitle {
          font-size: 12px;
          margin-left: 28px;
        }
      }
      
      .app-info {
        .server-info {
          font-size: 12px;
          padding: 6px 12px;
          border-radius: 10px;
        }
      }
    }
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  #app {
    .app-header {
      flex-direction: column;
      gap: 12px;
      text-align: center;
      padding: 16px 20px;
      
      .app-title {
        align-items: center;
        
        h1 {
          font-size: 18px;
          gap: 6px;
        }
        
        .app-subtitle {
          margin-left: 0;
          margin-top: 4px;
          font-size: 11px;
        }
      }
      
      .app-info {
        .server-info {
          font-size: 11px;
          padding: 4px 8px;
          border-radius: 8px;
        }
      }
    }
  }
}

// 现代化动画
@media (prefers-reduced-motion: no-preference) {
  * {
    scroll-behavior: smooth;
  }
}

// 深色模式支持准备
@media (prefers-color-scheme: dark) {
  // 可以在这里添加深色模式样式
}
</style>

